<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@page import="com.laputa.service.model.ShowGroundData"%>
<%@page import="com.laputa.model.Ground"%>
<%@page import="com.laputa.service.model.MainFrameData"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
	 <%
		ShowGroundData data = (ShowGroundData) request.getAttribute("showGroundData");
		Ground ground = data.getGround();
		request.setAttribute("groundID", ground.getId());
		String currentUserName = ((MainFrameData) request.getSession().getAttribute("userData")).getName();
		request.setAttribute("currentUserName", currentUserName);
		System.out.println("from showGround.jsp, currusername = " + currentUserName);
	 %>
	 
    <head>
		<base href="<%=basePath%>">
		<title>浏览土地信息</title> 
		<link rel="stylesheet" type="text/css" href="css/main.css">
	</head>

<body background="pic/background.jpg">

<table align="center" valign="top">
	<tr>
		<td align="left">
			<table width="100%" border="1" cellspacing="0" cellpadding="3">
				<%
					if (ground.getBuilding() == null)
					{
						out.print("<img name=\"ground0\" src=\"buildings/ground.png\" width=\"570\" height=\"440\" hspace=\"100\">");
					}else
					{
						out.print("<img name=\"ground0\" src=\"buildings/building" + ground.getBuilding().getType() + ".png\" width=\"570\" height=\"440\" hspace=\"100\">");
					}
				%>
				
				<tr>
					<td align="center" valign = "top"> 这块地属于 <% out.print(ground.getOwner()); %> </td>
				</tr>
				
				<tr>
					<td align="center" valign = "top"> 这块地现在被 <% out.print(ground.getUser());%> 使用 </td>						
				</tr>
				
	
				<form method="post" action="buy.do">
					<input type="hidden" name="groundID" value="${groundID}"/>
					<input type="submit" name="buy" value="购买"/>
				</form>
				<logic:equal name="currentUserName" value="<%=ground.getUser()%>">
					<form method="post" action="build.do">
						<input type="hidden" name="groundID" value="${groundID}"/>
						<input type="hidden" name="buildingType" value=""/>
						<input type="submit" name="build" value="建楼"/>
					</form>
				</logic:equal>
				<form method="post" action="login.do">
					<input type="submit" name="home" value="返回" />
				</form>
			</table>
		</td>
	</tr>
</table>

</body>
</html>
